package com.ta.lecture;

import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;

public class SharedPreferenceActivity extends Activity {
 static final String PREF_USERNAME = "PREF_USERNAME";
 static final String PREF_USE_JAVASCRIPT = "PREF_USE_JAVASCRIPT";
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  savePreference();
  readPreference();
 }
 
 void savePreference()
 {
  SharedPreferences pref = getSharedPreferences("setting", MODE_PRIVATE);
  SharedPreferences.Editor edit = pref.edit();
  edit.putBoolean("PREF_USE_JAVASCRIPT", false);
  edit.putString("PREF_USERNAME", "tacademy");
  edit.commit();
 }
 void readPreference()
 {
  SharedPreferences pref = getSharedPreferences("setting", MODE_PRIVATE);
  boolean useJs = pref.getBoolean("PREF_USE_JAVASCRIPT", true);
  String username = pref.getString("PREF_USERNAME", null);
  Log.d("TA", "useJs" + useJs + "/username" + username);
 }
}
